package top.iridescent.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import top.iridescent.dao.model.request.MhEquipmentInfoQuery;
import top.iridescent.entity.MhEquipmentInfo;
import top.iridescent.service.impl.MhEquipmentInfoServiceImpl;
import top.iridescent.util.PageUtils;
import top.iridescent.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 
 *
 * @author 
 * @email 
 * @date 2021-09-17 15:17:44
 */
@RestController
@Api(tags = "MhEquipmentInfo")
@RequestMapping("mh/mhequipmentinfo")
@CrossOrigin
public class MhEquipmentInfoController  {
    @Autowired
    private MhEquipmentInfoServiceImpl service;

    /**
     * 列表
     */
    @ApiOperation(value = "分页检索", notes = "")
    @PostMapping("/list")
    //@RequiresPermissions("mh:mhequipmentinfo:list")
    public Result findPage(@RequestBody MhEquipmentInfoQuery param){
        return service.findPage(PageUtils.getPage(param), param);
    }


    /**
     * 信息
     */
    @ApiOperation(value = "单个检索 ", notes = "")
    @GetMapping(value = "/{objId}", produces = "application/json")
    //@RequiresPermissions("mh:mhequipmentinfo:info")
    public Result getById(@ApiParam(name = "objId", value = "") @PathVariable Long objId){
        return service.getById(objId);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "新增", notes = "")
    @PostMapping(value = "", produces = "application/json")
    //@RequiresPermissions("mh:mhequipmentinfo:save")
    public Result save(@RequestBody MhEquipmentInfo param){
        //param.setOperId(((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUserId());
        return service.saveInfo(param);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "更新", notes = "")
    @PutMapping(value = "/{objId}", produces = "application/json")
    //@RequiresPermissions("mh:mhequipmentinfo:update")
    public Result update(@ApiParam(name = "objId", value = "") @PathVariable Long objId,@RequestBody MhEquipmentInfo param){
        param.setId(objId);
        //param.setOperId(((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUserId());
        return service.update(param);
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除", notes = "")
    @DeleteMapping(value = "/{objId}", produces = "application/json")
    //@RequiresPermissions("mh:mhequipmentinfo:delete")
    public Result deleteById(@ApiParam(name = "objId", value = "") @PathVariable Long objId){
        return service.deleteById(objId);
    }
    /**
     * 获取可用
     */
    @ApiOperation(value = "获取", notes = "")
    @GetMapping(value = "/all/{objId}", produces = "application/json")
    public Result getLS(@ApiParam(name = "objId", value = "0女1男") @PathVariable Long objId){
        return service.getNoUsedEQ(objId);
    }
}
